package com.k.base.jdk.enums;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

/**
 * 性别枚举类
 */
public enum GenderTypeEnum {
    MALE("0", "女"),
    FEMALE("1", "男");

    private final String value;
    private final String desc;

    GenderTypeEnum(String value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public String getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    // 匹配 value
    public static Optional<GenderTypeEnum> matchOpValue(String v) {
        return Arrays.stream(GenderTypeEnum.values()).filter(a -> a.value.equals(v)).findFirst();
    }

    // 枚举 MAP
    public static Map<String,String> selectMap;
    static {
        selectMap = new HashMap<>(8);
        for(GenderTypeEnum itm:GenderTypeEnum.values()){
            String value = itm.getValue();
            String desc = itm.getDesc();
            selectMap.put(value,desc);
        }
    }

}
